<!-- 登录页 -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form id="signInForm"> <!-- 注册表单 -->
        <div>
            <label for="">用户名<input type="text" name="name"></label>
        </div>
        <div>
            <label for="">密码<input type="password" name="password"></label>
        </div>
        <div>
            <button type="submit">登录</button>
        </div>
    </form>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script>
        const $form = $('#signInForm')
        $form.on('submit',(e)=>{
            e.preventDefault()
            const name = $form.find('input[name=name]').val()
            const password = $form.find('input[name=password]').val()
            console.log(name,password);
            $.ajax({
                method:'POST',
                url:'/sign_in',
                contentType:'text/json;charset=UTF-8',
                data:JSON.stringify({name,password})
            }).then(()=>{
                alert('登录成功')
                location.href='/home.html'
            },()=>{})
        })
    </script>
</body>
</html>